package com.xxxy.jsq.action.distrib;

import com.alibaba.fastjson2.JSONObject;
import com.xxxy.jsq.dao.DistribDao;
import com.xxxy.jsq.model.Distrib;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@WebServlet("/getDistribsServlet")
public class GetDistribsServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");

        DistribDao dao = new DistribDao();
        List<Distrib> list = dao.getAllky();

        JSONObject jo = new JSONObject();
        jo.put("data", list);

        PrintWriter out = response.getWriter();
        out.print(jo);
        out.flush();
        out.close();
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}